Ext.define('PJ.view.usermessagemanage.List', {
    extend: 'AM.default.DefaultList',
    alias: ['widget.trainingManagementList'],
    requires: ['AM.default.DefaultSearchForm',
               'AM.default.DateTime', 
               'AM.default.DefaultDateField',
               'AM.default.DefaultDoubleDateField',
               'AM.default.jsonp.DefaultLoadJsonp',//jsonp加载数据
		       'AM.default.DefaultActiveStateCombo'
		      // 'PJ.view.quotamanagement.PlanPlacesList'//计划名额
               ],
               initComponent: function(){
                  	var me= this;
                  	this.columns = [{
                  		header: '学员账号',
                  		dataIndex: 'u.LOGIN_ID',
                  		width: 80,
                  		renderer: function(value, metaData, record){
                  			//meta.style = "white-space:normal;cursor: pointer;color:blue;";
                  			metaData.tdAttr = 'data-qtip="' + value + '"';
                  			return value;
                  		}
                  	},{
                          header: '姓名',
                          dataIndex: 'u.USER_NAME',
                          //flex: 1,
                          minWidth: 80,
                  		renderer: function(value, metaData, record){
                  			metaData.tdAttr = 'data-qtip="' + value + '"';
                  			return value;
                  		}
                      },{
                          header: '出生年月',
                          dataIndex: 'u.BIRTHDAY',
                          width: 100,
                  		renderer: function(value, metaData, record){
                  			metaData.tdAttr = 'data-qtip="' + value + '"';
                  			return value;
                  		}
                      },{
                          header: '性别',
                          dataIndex: 'ub.DATA_NAME',
                          width: 60,
                          renderer: function(value, meta, record){
                          	meta.tdAttr = "data-qtip='" + value + "'";
                          	return value;
                          }
                      },{
                          header: '所在单位',
                          dataIndex: 'ud1.DEPNAME',
                          flex: 1,
                          width: 120,
                          renderer: function(value, metaData, record){
                          	if (value == "西城区") {
			      				value = "西城区委组织部";
			      			}
                  			metaData.tdAttr = 'data-qtip="' + value + '"';
                  			return value;
                  		}
                      },{
                          header: '职级',
                          dataIndex: 'ub2.DATA_NAME',
                          width: 120,
                          renderer: function(value, metaData, record){
                  			metaData.tdAttr = 'data-qtip="' + value + '"';
                  			return value;
                  		}
                      },{
                          header: '职务',     /*'已报人数/计划人数',*/
                          dataIndex: 'u.DUTY_REMARK',
                          width: 80,
                          renderer: function(value, metaData, record){
                          	metaData.tdAttr = 'data-qtip="' + value + '"';
                          	return value /*+ '/' + record.get('classUserNum')*/;
                          }
                      },{
                          header: '身份',
                          dataIndex: 'statusCodes',
                          sortable: false,
                          renderer: function(value, metaData, record){
                          	metaData.tdAttr = 'data-qtip="' + value + '"';
                          	return value ;
                          },
                          width: 70
                      },{
                          header: '市管干部',
                          dataIndex: 'u.SHIGUAN',
                          renderer: function(v, metaData, record){
                          	
                          	if(v == 1) {
                          		return '市管';
                               //return '<span style="color:green;">' + '已开班' + '</span>';
                            }else if(v == 0) {
                              return '非市管';
                            }else{
                              return '非市管';
                            }
                          	
                          },
                          width: 70
                      },{
                          header: '考核状态',
                          dataIndex: 'u.EXAM_STATE',
                          renderer : function(v, metaData, record) {
							if (v == 1) {
								return '考核';
							} else if (v == 0) {
								return '非考核';
							}
			
						},
                          width: 70
                      },{
                          header: '修改状态',
                          dataIndex: 'utu.UPDATE_STATE',
                          renderer : function(v, metaData, record) {
							if (v == 1) {
								return '已修改';
							} else if (v == 0) {
								return '未修改';
							}
			
						},
                          width: 70
                      },{
                          header: '报名状态',
                          dataIndex: 'u.AVAILABILITY_STATE',
                          renderer : function(v, metaData, record) {

							if (v == 1) {
								return '有效';
							} else if (v == 0) {
								return '无效';
							}
			
						},
                          width: 70
                      }, {
                          header: '维护个人信息',
                          sortable: false,
                          renderer: function(value, meta, record){
                          	meta.style = "cursor: pointer;color:blue;";
                          	value = '维护个人信息';
                          	meta.tdAttr = "data-qtip='" + value + "' userID=" + record.get("userID");
                          	return value;
                          },
                          listeners: {
                  			click: function(g, clm){
                  				var userID = clm.getAttribute("userID");
                  				win = Ext.create('PJ.view.usermessagemanage.Edit', {
                  					title: "更新用户基本信息",
                  					flag:4,
                  					grid: me,
                  					isDisable:false,
                  					isReadOnly:true
                  				}).show();
                  				var actionName = "load";
                  				if(gj_onlineLearning_constant.loadType == "jsonp"){
                  					actionName = "loadJsonp";
                  				}
                  				win.down("form").getForm().doAction(actionName,{
                  					url:me.store.preUpdateUrl,
                  					params:{
                  						searchUsertId: userID
                  					}
                  				});
                  			}
                  		},
                          width: 100
                      }];
                  	
                      this.store = Ext.create('PJ.'+ prototype +'.usermessagemanage.List',{
                      	isLoad: true
                      });
                      this.callParent(arguments);
                      this.loadType = gj_onlineLearning_constant.loadType;//加载方式
                  },
                 //导出
                  
                  onExportClick:function(){
				    	var me = this;
				        var store = me.getStore();
				        var params=store.proxy.extraParams;
				        var href=me.store.exportExcelUrl + "?page=-1";
				        for(var param in params){
				        	if(params[param] === undefined){
				        		href+="&"+param+"=";
				        	}else{
				        		href+="&"+param+"="+params[param];
				        	}
				        }
				        href = encodeURI(href);
				        var atag = Ext.get("exportResume");
				        atag.set({
				            "href": href
				        });
				        atag.dom.click();
				    },
                  
                  
                  
                  
                  listeners: {
              		selectionchange: function(selModel, selected){
              			//this.down('#' + this.oldId + "Configuration").setDisabled(selected.length === 0);//配置课程
              		},
              		viewready: function(){
              			var me = this;
              			this.addDocked([{
              				dock: 'top',
              				xtype: "searchform",
              				columnCount: 3,
              				fieldDefaults: {
              					labelAlign: 'right',
              					labelWidth: 100
              				},
              				items: [{
              					xtype: "combo",
              					fieldLabel: '身份',
              					name: "searchStatusCodes",
              					store: Ext.create("Ext.data.ArrayStore", {
			                		singleton: true,
			                		fields: [{
			                			name: 'value',
			                			mapping: "dataCode",
			                			type: 'string'
			                		}, {
			                			name: 'text',
			                			mapping: "dataName",
			                			type: 'string'
			                		}],
			                		proxy: {
			                			type: gj_onlineLearning_constant.loadType,
			                			url: this.store.rankTypeUrl + '?typeCode=A0301',
			                			reader: Ext.create('Ext.data.reader.Json', {
			                				type: 'json',
			                				root: 'data',
			                				successProperty: 'success'
			                			})
			                		},
			                		autoLoad: true
			                	}),
              					valueField: 'value',
              					displayField: 'text',
              					editable: false,
              					multiSelect: true,
              					emptyText: "请选择"
              				},{
              					xtype: "textfield",
              					fieldLabel: '学员账号',
              					name: "searchLoginId",
              					maxLength: "50",
              					emptyText: "请输入学员账号"
              				},{
			                	xtype:"combo",
			                    fieldLabel: "职级",
			                    name: "searchrankCode",
			                    emptyText: "请选择",
			    				labelAlign: 'right',
			                   // columnWidth:.5,
			                	store: Ext.create("Ext.data.ArrayStore", {
			                		singleton: true,
			                		fields: [{
			                			name: 'value',
			                			mapping: "dataCode",
			                			type: 'string'
			                		}, {
			                			name: 'text',
			                			mapping: "dataName",
			                			type: 'string'
			                		}],
			                		proxy: {
			                			type: gj_onlineLearning_constant.loadType,
			                			url: this.store.rankTypeUrl + '?typeCode=1228',
			                			reader: Ext.create('Ext.data.reader.Json', {
			                				type: 'json',
			                				root: 'data',
			                				successProperty: 'success'
			                			})
			                		},
			                		autoLoad: true
			                	}),
			        			valueField: 'value',
			        			displayField: 'text',
			        			editable: false,
			        			defaultActive: false
			                }, {
              					xtype: "textfield",
              					fieldLabel: '学员姓名',
              					name: "searchUserName",
              					maxLength: "50",
              					emptyText: "请输入学员姓名"
              				}, {
              					xtype: "combo",
              					fieldLabel: '市管干部',
              					name: "searchSiGuan",
              					store: Ext.create("Ext.data.ArrayStore", {
              						fields: ['value', 'text'],
              						data: [[1, '市管'],[0,'非市管']]
              					}),
              					valueField: 'value',
              					displayField: 'text',
              					editable: false,
              					emptyText: "请选择"
              				}],
              				grid: this
              			},{
              				xtype: 'toolbar',
              				dock: 'top',
              				displayInfo: true,
              				items: [{
			                    text: '导出',
			                    iconCls: 'deriveIco',
			                    itemId: this.oldId + "Export",
			                    disabled: false,
			                    scope: this,
			                    handler: this.onExportClick
			                },"->", this.countSelectPanel]
              			}]);
                          // 触发权限过滤事件
                          me.fireEvent("permission", this);
              		}
                  }
              });
